#!/usr/bin/python
# -*- coding: UTF-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import cv2
import numpy as np


def get_rotation_matrix(rotate_center_pt, rotate_angle, scale=1.0):
    # 获取旋转矩阵
    rotate_matrix = cv2.getRotationMatrix2D(rotate_center_pt, rotate_angle, scale)
    return rotate_matrix


def calcul_rotate_matrix(rotate_angle, image_width, image_height):
    # 计算旋转矩阵
    center_pt = (image_width // 2, image_height // 2)
    rotate_matrix = get_rotation_matrix(center_pt, rotate_angle)
    return rotate_matrix


def image_rotate(image_input, k=1):
    return np.rot90(image_input, k)
    # rotate_angle_dict = {"-3": 270, "-2": -180, "-1": -90, "0": 0, "1": 90, "2": 180, "3": 270}
    # rotate_matrix = calcul_rotate_matrix(rotate_angle_dict[str(k)], image_input.shape[1], image_input.shape[0])
    # test = cv2.warpAffine(image_input, rotate_matrix, (image_input.shape[1], image_input.shape[0]))
    # return test


def image_flip(image_input, k=1):
    # k=0垂直翻转， k=1水平翻转
    return cv2.flip(image_input, k)


def image_resize(image_input):
    return 0

#
# if __name__ == "__main__":
#     path = r'C:\Users\admin\Desktop\dt\test.bmp'  # place path to your image here
#     image_cv = cv2.imread(path, -1)
#     gau = image_flip(image_cv, 1)
#     cv2.imshow("Operation", gau)
#     cv2.waitKey(0)
#
#     gau = image_flip(gau, 1)
#     cv2.imshow("Operation", gau)
#     cv2.waitKey(0)
#
#     # img180 = np.rot90(image_cv, 1)
#     # cv2.imshow("rotate", img180)
#     # cv2.waitKey(0)


